<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>导师详情-思多客</title>
    <link href="http://cdn.bootcss.com/normalize/7.0.0/normalize.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/public/css/m/public.css">
    <link rel="stylesheet" href="/public/css/m/teacher.css">
</head>
<body>
    <div class="n-page">
        <div class="new-header flex">
            <div class="back-box">
                <img src="/public/images/m/back.png" alt="" class="left-back-icon">
            </div>
            <span class="header-title flex-child-box">老师信息</span>
        </div>
        <div class="content">
            <div class="reward-form-box1">
                <div class="teacher-msg flex" id="J_teacher_info"></div>
                <h3 class="teach-zp-title">最新发表:</h3>
                <ul class="clearfix" id="J_recent_report"></ul>
                <h3 class="teach-zp-title">精品推荐:</h3>
                <ul class="clearfix" id="J_recommend_report"></ul>
            </div>
        </div>
    </div>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/public/js/m/fontResize.js"></script>
    <script src="/public/lib/layer/layui.js"></script>
    <script src="/public/js/G.js"></script>
    <script src="/public/js/product.js"></script>
    <script src="/public/js/teacher.js"></script>
    <script src="/public/js/attention.js"></script>
    <script src="/public/js/m/public.js"></script>
    <script id="J_teacher_info_tpl" type="text/html">
        <div class="teach-header">
            <div><img src="{{G.defaultAvator}}" alt="{{d.base.name}}" data-lazyload-img="{{G.uploadurl}}/avator/{{d.userId}}.png">
            <span>{{d.base.aliasName?d.base.aliasName:d.base.name}}</span></div>
        </div>
        <div class="teach-message">
            <div class="tache-title">{{d.base.teacherType}}/{{formatVal(d.base.educationalBackgroundValue)}}</div>
            <div class="teach-msg-detail">
                <span class="teach-item">年龄:{{formatVal(d.user.age)}}</span>
                <span class="teach-item">从业时间:{{d.base.jobTime ? new Date(d.base.jobTime).format("YYYY-mm") : "-"}}</span>
                <span class="teach-item">累计获赏：{{d.extend.exceptionalMoney}}元</span>
            </div>
            <div class="teach-msg-detail">
                <span class="teach-item">性别:{{genderShow(d.user.gender)}}</span>
                <span class="teach-item">关注人数:{{d.extend.attentionNumber}}</span>
                <span class="teach-item">累计发表报告：{{d.extend.contributeNumber}}篇</span>
            </div>
            <div class="teach-score">平均战绩:<span class="win-total-num">{{formatVal(d.correct5)}}%</span>上期战绩:<span class="win-total-num">{{formatVal(d.correct1)}}%</span>
            {{# if (G.getCookie("sdk_user_type") == "USER" && G.getCookie("sdk_user_id")) {}}
                <input type="button" class="follow {{# if(!d.attentioned){ }}hide{{# } }}" id="J_off_attention" data-teacherid="{{d.userId}}" value="取消关注"> 
                <input type="button" class="follow {{# if(d.attentioned){ }}hide{{# } }}" id="J_attention" data-teacherid="{{d.userId}}" value="+ 关注TA">
            {{# }; }}
            </div>
        </div>
    </script>
    <script id="J_reports_tpl" type="text/html">
        {{# if(d.length){ }}
            {{# d.forEach(function(val,index){ }}
            <li class="zp-box">
                <h4 class="zp-bh">{{val.title}}</h4>
                <p class="center">发布时间<br>{{new Date(val.createTime).format('YYYY-MM-DD')}}</p>
                <p class="center">下载量</p>
                <p class="center">{{val.downloadNumber}}</p>
                {{# if (val.free) { }}
                    <a href="{{G.apiurl}}api/product/{{val.productId}}/download?token={{G.getCookie('jwt')}}" class="download" data-id="{{val.productId}}">免费下载</a>
                {{# } else if (val.payed) { }}
                    <a href="{{G.apiurl}}api/product/{{val.productId}}/download?token={{G.getCookie('jwt')}}" class="download" data-id="{{val.productId}}">下载</a>
                {{# } else { }}
                    <a href="/m/payment.html?money={{val.promotionsPrice}}&type=report&title={{val.title}}&userId={{val.teacherId}}&tName={{val.teacherName}}&outline={{val.outline?val.outline:val.nowContent}}&productId={{val.productId}}&productType={{val.type}}" class="download J_buy_product">打赏{{val.promotionsPrice}}</a>
                {{# } }}
            </li>
            {{# }); }}
        {{# }else{ }}
            <li class="center"><img src="/public/images/m/no_content.png" alt="暂无内容"></li>
        {{# }; }}
    </script>
    <script>
        layui.use('laytpl', function() {
            var laytpl = layui.laytpl;

            isLogined()
            var tid = G.getQuery('tid');
            loading.open();
            teacher.findOne(tid, {}, function(data) {
                console.log(data)
                laytpl($('#J_teacher_info_tpl').html()).render(data, function(html) {
                    $('#J_teacher_info').html(html)
                })
                lazyload()
                reports(tid, '#J_recent_report', false);
                reports(tid, '#J_recommend_report', true);
                loading.close();
            }, function(err){
                loading.close();
                alert(err)
            })

            //获取老师报告
            function reports(tid, dom, quintessence) {
                product.getList({
                    teacherId: tid,
                    pageSize: 8,
                    quintessence: quintessence
                }, function(data) {
                    laytpl($('#J_reports_tpl').html()).render(data.list, function(list) {
                        $(dom).html(list)
                    })
                })
            }
        })

        $(document).on("click", "#J_attention", function() {//关注
            var id = $(this).attr("data-teacherid");
            attentionApi.put(id, function() {
                $("#J_attention").addClass("hide");
                $("#J_off_attention").removeClass("hide");
                console.log("关注成功")
            })
        }).on('click','#J_off_attention',function(){//取消关注
            var id = $(this).attr("data-teacherid");
            attentionApi.delete(id,function(){
                $("#J_attention").removeClass("hide");
                $("#J_off_attention").addClass("hide");
                console.log('取消关注成功')
            })
        })
    </script>
</body>
</html>